﻿using System;
using System.ComponentModel.DataAnnotations;
using System.Runtime.Serialization;
using Zero.Common;

namespace Example.Entities
{
    [DataContract(IsReference = true)]
    [KnownType(typeof(Customer))]
    public class Order : EntityObject
    {
        [DataMember, Key, Required]
        public int Id
        {
            get { return _id; }
            set
            {
                if (_id != value)
                {
                    _id = value;
                    OnPropertyChanged("Id");
                }
            }
        }
        private int _id;

        [DataMember, Required]
        public DateTime PlacedDate
        {
            get { return _placedDate; }
            set
            {
                if (_placedDate != value)
                {
                    _placedDate = value;
                    OnPropertyChanged("PlacedDate");
                }
            }
        }

        private DateTime _placedDate;

        [DataMember]
        public DateTime? PaidDate
        {
            get { return _paidDate; }
            set
            {
                if (_paidDate != value)
                {
                    _paidDate = value;
                    OnPropertyChanged("PaidDate");
                }
            }
        }

        private DateTime? _paidDate;

        [DataMember, Required]
        public decimal Cost
        {
            get { return _cost; }
            set
            {
                if (_cost != value)
                {
                    _cost = value;
                    OnPropertyChanged("Cost");
                }
            }
        }

        private decimal _cost;

        [DataMember]
        public Customer Owner
        {
            get { return _owner; }
            set
            {
                if (_owner != value)
                {
                    _owner = value;
                    OnPropertyChanged("Owner");
                }
            }
        }

        private Customer _owner;
    }
}
